﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Antu.WebControls;
using Antu.Core.Components;
using Antu.Core.Services;
using System.Web.UI.WebControls;
using EluZSProvider;
using System.Web;
using System.Data;

namespace WebSys.UI.Control.ZhengShou
{
    public class MCSQControl : MPBasicTemplate
    {
        EluZSDataProvider _EluZSDataProvider = (EluZSDataProvider)ProviderService.ProviderServiceMange.GetProvider("EluZSProvider");
        public string userid = string.Empty;
        protected override void OnLoad(EventArgs e)
        {
            if (HttpContext.Current.Session["UserID"] == null)
            {
                Antu.Utilities.UtilitiesPage.AlertDialogClear("登录超时，请重新登录！", "window.parent.location.href('../login.aspx');");
            }
            else
            {
                userid = HttpContext.Current.Session["UserID"].ToString();
            }
            base.OnLoad(e);
            if (!base.Page.IsPostBack)
            {
                BindData();
            }
        }
        protected void BindData() {
            MPRepeater MPRepeaterList = (MPRepeater)FindControl("MPRepeaterList");
            string sql = @"Select t.rolename,t.id,
(Select Count(Id) From ZS_MCYHCQB Where roleid =t.id And 用户类型='监管用户') 监管用户,
(Select Count(Id) From ZS_MCYHCQB Where roleid =t.id And 用户类型='管理用户') 管理用户,
(Select Count(Id) From ZS_MCYHCQB Where roleid =t.id And 用户类型='项目用户') 项目用户 
 From zs_role t Where rolename Like '%征收部门%'";
            string strwhere = string.Empty;
            if (!_EluZSDataProvider.IsZSAdmin(userid) && !_EluZSDataProvider.IsNetZSAdmin(userid)&&!_EluZSDataProvider.IsSZSB(userid))
            {
                strwhere = " and id in (select roleid from zs_user_in_role where userid='" + userid + "') ";
            }
            sql += strwhere;
            DataTable dt = _EluZSDataProvider.GetTable(sql);
            MPRepeaterList.DataSource = dt;
            MPRepeaterList.DataBind();
        }

        #region 原有错误
        //public string BindData(string qsname,string usertype){
        //    string sql = string.Empty;
        //    if (string.IsNullOrEmpty(usertype))
        //    {
        //         sql = "Select count(*) from zs_mcyhcqb where 区属 = '"+qsname+"'";
        //    }
        //    else
        //    {
        //         sql = "Select count(*) from zs_mcyhcqb where 区属 = '"+qsname+"' and  用户类型 ='"+usertype+"' ";
        //    }       
          
        //    return _EluZSDataProvider.GetString(sql);
        //}
        //public void DataBind()
        //{
        //    Label gljgyh = (Label)FindControl("gljgyh");
        //    gljgyh.Text = BindData("鼓楼区", "监管用户");
        //    Label glglyh = (Label)FindControl("glglyh");
        //    glglyh.Text = BindData("鼓楼区", "管理用户");
        //    Label glxmyh = (Label)FindControl("glxmyh");
        //    glxmyh.Text = BindData("鼓楼区", "项目用户");

        //    Label xwjgyh = (Label)FindControl("xwjgyh");
        //    xwjgyh.Text = BindData("玄武区", "监管用户");
        //    Label xwglyh = (Label)FindControl("xwglyh");
        //    xwglyh.Text = BindData("玄武区", "管理用户");
        //    Label xwxmyh = (Label)FindControl("xwxmyh");
        //    xwxmyh.Text = BindData("玄武区", "项目用户");

        //    Label jnjgyh = (Label)FindControl("jnjgyh");
        //    jnjgyh.Text = BindData("江宁区", "监管用户");
        //    Label jnglyh = (Label)FindControl("jnglyh");
        //    jnglyh.Text = BindData("江宁区", "管理用户");
        //    Label jnxmyh = (Label)FindControl("jnxmyh");
        //    jnxmyh.Text = BindData("江宁区", "项目用户");

        //    Label lhjgyh = (Label)FindControl("lhjgyh");
        //    lhjgyh.Text = BindData("六合区", "监管用户");
        //    Label lhglyh = (Label)FindControl("lhglyh");
        //    lhglyh.Text = BindData("六合区", "管理用户");
        //    Label lhxmyh = (Label)FindControl("lhxmyh");
        //    lhxmyh.Text = BindData("六合区", "项目用户");

        //    Label lsjgyh = (Label)FindControl("lsjgyh");
        //    lsjgyh.Text = BindData("溧水县", "监管用户");
        //    Label lsglyh = (Label)FindControl("lsglyh");
        //    lsglyh.Text = BindData("溧水县", "管理用户");
        //    Label lsxmyh = (Label)FindControl("lsxmyh");
        //    lsxmyh.Text = BindData("溧水县", "项目用户");

        //    Label gcjgyh = (Label)FindControl("gcjgyh");
        //    gcjgyh.Text = BindData("高淳县", "监管用户");
        //    Label gcglyh = (Label)FindControl("gcglyh");
        //    gcglyh.Text = BindData("高淳县", "管理用户");
        //    Label gcxmyh = (Label)FindControl("gcxmyh");
        //    gcxmyh.Text = BindData("高淳县", "项目用户");

        //    Label bxjgyh = (Label)FindControl("bxjgyh");
        //    bxjgyh.Text = BindData("白下区", "监管用户");
        //    Label bxglyh = (Label)FindControl("bxglyh");
        //    bxglyh.Text = BindData("白下区", "管理用户");
        //    Label bxxmyh = (Label)FindControl("bxxmyh");
        //    bxxmyh.Text = BindData("白下区", "项目用户");

        //    Label jyjgyh = (Label)FindControl("jyjgyh");
        //    jyjgyh.Text = BindData("建业区", "监管用户");
        //    Label jyglyh = (Label)FindControl("jyglyh");
        //    jyglyh.Text = BindData("建业区", "管理用户");
        //    Label jyxmyh = (Label)FindControl("jyxmyh");
        //    jyxmyh.Text = BindData("建业区", "项目用户");

        //    Label qhjgyh = (Label)FindControl("qhjgyh");
        //    qhjgyh.Text = BindData("秦淮区", "监管用户");
        //    Label qhglyh = (Label)FindControl("qhglyh");
        //    qhglyh.Text = BindData("秦淮区", "管理用户");
        //    Label qhxmyh = (Label)FindControl("qhxmyh");
        //    qhxmyh.Text = BindData("秦淮区", "项目用户");

        //    Label xgjgyh = (Label)FindControl("xgjgyh");
        //    xgjgyh.Text = BindData("下关区", "监管用户");
        //    Label xgglyh = (Label)FindControl("xgglyh");
        //    xgglyh.Text = BindData("下关区", "管理用户");
        //    Label xgxmyh = (Label)FindControl("xgxmyh");
        //    xgxmyh.Text = BindData("下关区", "项目用户");

        //    Label xxjgyh = (Label)FindControl("xxjgyh");
        //    xxjgyh.Text = BindData("栖霞区", "监管用户");
        //    Label xxglyh = (Label)FindControl("xxglyh");
        //    xxglyh.Text = BindData("栖霞区", "管理用户");
        //    Label xxxmyh = (Label)FindControl("xxxmyh");
        //    xxxmyh.Text = BindData("栖霞区", "项目用户");

        //    Label yhtjgyh = (Label)FindControl("yhtjgyh");
        //    yhtjgyh.Text = BindData("雨花台区", "监管用户");
        //    Label yhtglyh = (Label)FindControl("yhtglyh");
        //    yhtglyh.Text = BindData("雨花台区", "管理用户");
        //    Label yhtxmyh = (Label)FindControl("yhtxmyh");
        //    yhtxmyh.Text = BindData("雨花台区", "项目用户");

        //    Label pkjgyh = (Label)FindControl("pkjgyh");
        //    pkjgyh.Text = BindData("浦口区", "监管用户");
        //    Label pkglyh = (Label)FindControl("pkglyh");
        //    pkglyh.Text = BindData("浦口区", "管理用户");
        //    Label pkxmyh = (Label)FindControl("pkxmyh");
        //    pkxmyh.Text = BindData("浦口区", "项目用户");
        //}
        #endregion
    }
}
